package algorithm;

import herd.Krill;
import utils.Position;

import java.util.Random;

public class AlgorithmParameters {
    public final double MAX_DIFFUSION = 0.005; //from range  [0.002, 0.01]
    public final double N_MAX = 0.01;
    public final double Vf = 0.02;
    public final double inertiaWeight = 0.5; // from range [0,1]
    public final double inertiaForagingWeight = 0.5; // from range [0,1]
    public final int herdSize = 10;
    public final Position minPosition = new Position(-10.0,-10.0);
    public final Position maxPosition = new Position(10.0,10.0);

    private final int maxIteration = 100;
    private int currentIteration = 0;
    private boolean criteriaReached = false;

    private Krill bestFitnessKrill;
    private double bestFitnessValue;
    private double worstFitnessValue;

    private final Random random = new Random(44);

    public boolean nextIteration(){
        if(currentIteration < maxIteration && !criteriaReached){
           currentIteration++;
            return true;
        }
        return false;
    }

    public int getMaxIteration() {
        return maxIteration;
    }

    public int getCurrentIteration() {
        return currentIteration;
    }

    public void setBestFitnessValue(double bestFitnessValue) {
        this.bestFitnessValue = bestFitnessValue;
    }

    public void setWorstFitnessValue(double worstFitnessValue) {
        this.worstFitnessValue = worstFitnessValue;
    }

    public double getRelatedFitnessValue(){
        return bestFitnessValue - worstFitnessValue;
    }

    public Krill getBestFitnessKrill() {
        return bestFitnessKrill;
    }

    public void setBestFitnessKrill(Krill bestFitnessKrill) {
        this.bestFitnessKrill = bestFitnessKrill;
    }

    public double getIterationRatio(){
        return (double)currentIteration / (double)maxIteration;
    }

    public double randomizeDMAX(){
        //range [2,10]
        double ran = (random.nextDouble() * 8.0) + 2.0;
        return ran/1000.0;
    }
}
